﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace XEvents.Addin
{
    public class XEventTreeNode : TreeNode
    {
        public XEventTreeNode()
        {

        }

        public XEventTreeNode(string name)
        {
            Text = name;
            Name = name;
        }

        public XEventTreeNode(XmlNode xNode)
        {
            Tag = xNode;
        }

        public XEventTreeNode(string name, XmlNode xNode)
        {
            Name = name;
            Text = name;
            Tag = xNode;

            this.SelectedImageKey = this.getImageKey;
            this.ImageKey = this.getImageKey;
        }

        public string getImageKey
        {
            get
            {
                XmlNode xNode = (XmlNode)Tag;
                switch (xNode.Name)
                {
                    case "EventSession":
                        if (xNode.Attributes["SessionState"].Value == "Start")
                            return "startedSessionImage";
                        else
                            return "stoppedSessionImage";
                    case "EventSessionEvent":
                        return "columnImage";
                    case "Action":
                        return "columnImage";
                    case "TargetOption":
                        return "columnImage";
                    case "ArrayOfEventSession":
                        return "SqlServerImage";
                    default:
                        return "folderImage";
                }
            }
        }
        
    }
}
